*************   Do-file for: Supplementary Appendix (Study 2)   ****************
*************   Date Modified: 09/09/2020  	                    ****************
*************   Created by: Adam D. Wolsky  	                ****************

clear
cd "/Users/adamwolsky/Dropbox/Vandy/Projects/Hypocrisy_Scandal/Analysis/Study2_Conyers/Data/"
use "study2_clean.dta"
set more off

/*   download user-written command cibar; type "ssc install outreg2" */

cd "/Users/adamwolsky/Dropbox/Vandy/Projects/Hypocrisy_Scandal/Analysis/Study2_Conyers/Logs/"

log using sa_study2_log, replace name("SA Study 2 Log File")

********************************    Table 2A    ********************************

cd "/Users/adamwolsky/Dropbox/Vandy/Projects/Hypocrisy_Scandal/Tables"

outreg2 using descriptive_study2.doc, replace sum(log) ///
keep(female high_ed age hisp black asian partisan rep_other_dummy dem_other_dummy)

*****************************   Table 4A (Col 2)   *****************************

mlogit expcond female edu black hisp asian age news dem_other_dummy rep_other_dummy, b(1)
outreg2 using balance1.doc, append addstat(LR chi2(16), e(chi2), p, e(p)) ctitle(Conyers) long

********************************    Table 8A    ********************************

reg demtherm i.t2vt1##i.pid7 if democrat == 1
outreg2 using conyerspidh1.doc, replace

********************************    Table 9A    ********************************

reg demtherm i.t3vt2##i.pid7 if democrat == 1
outreg2 using conyerspidh2.doc, replace

*******************************    Table 10A    ********************************

reg reptherm i.t2vt1##i.pid7 if republican == 1
outreg2 using conyerspidh3.doc, replace

*******************************    Figure 4A    ********************************

cd "/Users/adamwolsky/Dropbox/Vandy/Projects/Hypocrisy_Scandal/Figures"

reg demtherm i.t2vt1##i.pid7 if democrat == 1
margins, at(t2vt1=(0(1)1) pid7=(1(1)3)) level(90)
marginsplot, xtitle(" ") recast(bar) by(pid7) byopt(title(" ") row(1)) ///
plotopts(barw(.8) color(white) lcolor(black)) recastci(rspike) ysize(2.5) ///
xlabel(0 "Scandal" 1 "Hypocrisy")
graph export "fig4a.pdf", replace as(pdf) 

*******************************    Figure 5A    ********************************

reg demtherm i.t3vt2##i.pid7 if democrat == 1
margins, at(t3vt2=(0(1)1) pid7=(1(1)3)) level(90)
marginsplot, xtitle(" ") recast(bar) by(pid7) byopt(title(" ") row(1)) ///
plotopts(barw(.8) color(white) lcolor(black)) recastci(rspike) ysize(2.5) ///
xlabel(0 "Hypocrisy" 1 "Resignation")
graph export "fig5a.pdf", replace as(pdf) 

*******************************    Figure 6A    ********************************

reg reptherm i.t2vt1##i.pid7 if republican == 1
margins, at(t2vt1=(0(1)1) pid7=(5(1)7)) level(90)
marginsplot, xtitle(" ") recast(bar) by(pid7) byopt(title(" ") row(1)) ///
plotopts(barw(.8) color(white) lcolor(black)) recastci(rspike) ysize(2.5) ///
xlabel(0 "Scandal" 1 "Hypocrisy")
graph export "fig6a.pdf", replace as(pdf)

*******************************    Table 14A    ********************************

cd "/Users/adamwolsky/Dropbox/Vandy/Projects/Hypocrisy_Scandal/Tables"

reg demtherm i.t2vt1##i.vclosenews if democrat == 1
outreg2 using conyersnewsh1.doc, replace

*******************************    Table 15A    ********************************

reg demtherm i.t3vt2##i.vclosenews if democrat == 1
outreg2 using conyersnewsh2.doc, replace

*******************************    Table 16A    ********************************

reg reptherm i.t2vt1##i.vclosenews if republican == 1
outreg2 using conyersnewsh3.doc, replace

*******************************    Figure 10A   ********************************

cd "/Users/adamwolsky/Dropbox/Vandy/Projects/Hypocrisy_Scandal/Figures"

reg demtherm i.t2vt1##i.vclosenews if democrat == 1
margins, at(t2vt1=(0(1)1) vclosenews=(0(1)1)) level(90)
marginsplot, xtitle(" ") recast(bar) by(vclosenews) byopt(title(" ") row(1)) ///
plotopts(barw(.8) color(white) lcolor(black)) recastci(rspike) ysize(3) ///
xlabel(0 "Scandal" 1 "Hypocrisy")
graph export "fig10a.pdf", replace as(pdf) 

*******************************    Figure 11A   ********************************

reg demtherm i.t3vt2##i.vclosenews if democrat == 1
margins, at(t3vt2=(0(1)1) vclosenews=(0(1)1)) level(90)
marginsplot, xtitle(" ") recast(bar) by(vclosenews) byopt(title(" ") row(1)) ///
plotopts(barw(.8) color(white) lcolor(black)) recastci(rspike) ysize(3) ///
xlabel(0 "Hypocrisy" 1 "Resignation")
graph export "fig11a.pdf", replace as(pdf) 

*******************************    Figure 12A   ********************************

reg reptherm i.t2vt1##i.vclosenews if republican == 1
margins, at(t2vt1=(0(1)1) vclosenews=(0(1)1)) level(90)
marginsplot, xtitle(" ") recast(bar) by(vclosenews) byopt(title(" ") row(1)) ///
plotopts(barw(.8) color(white) lcolor(black)) recastci(rspike) ysize(3) ///
xlabel(0 "Scandal" 1 "Hypocrisy")
graph export "fig12a.pdf", replace as(pdf)

*******************************   Table 20A   **********************************

cd "/Users/adamwolsky/Dropbox/Vandy/Projects/Hypocrisy_Scandal/Tables"

reg demtherm i.t2vt1##i.democrat age edu female black hisp asian
outreg2 using conyersrobusth1.doc, replace

reg demtherm i.t2vt1##i.democrat age edu female black hisp asian if detroit_mm == 0
outreg2 using conyersrobusth1.doc, append

reg demtherm i.t2vt1##i.democrat##i.conyers_race age edu female black hisp asian if detroit_mm == 0
outreg2 using conyersrobusth1.doc, append

reg demtherm i.t2vt1##i.democrat age edu female black hisp asian if detroit_mm == 0 & conyers_race == 0
outreg2 using conyersrobusth1.doc, append

*******************************   Table 21A   **********************************

reg demtherm i.t3vt2##i.democrat age edu female black hisp asian
outreg2 using conyersrobusth2.doc, replace

reg demtherm i.t3vt2##i.democrat age edu female black hisp asian if detroit_mm == 0
outreg2 using conyersrobusth2.doc, append

reg demtherm i.t3vt2##i.democrat##i.conyers_race age edu female black hisp asian if detroit_mm == 0
outreg2 using conyersrobusth2.doc, append

reg demtherm i.t3vt2##i.democrat age edu female black hisp asian if detroit_mm == 0 & conyers_race == 0
outreg2 using conyersrobusth2.doc, append

*******************************   Table 22A   **********************************

reg reptherm i.t2vt1##i.republican age edu female black hisp asian
outreg2 using conyersrobusth3.doc, replace

reg reptherm i.t2vt1##i.republican age edu female black hisp asian  if detroit_mm == 0
outreg2 using conyersrobusth3.doc, append

reg reptherm i.t2vt1##i.republican##i.conyers_race age edu female black hisp asian if detroit_mm == 0
outreg2 using conyersrobusth3.doc, append

reg reptherm i.t2vt1##i.republican age edu female black hisp asian if detroit_mm == 0 & conyers_race == 0
outreg2 using conyersrobusth3.doc, append

* Data Audit * 

ttest demtherm if democrat == 1 & duplicate_ip == 0, by(t2vt1)
ttest demtherm if democrat == 1 & duplicate_ip == 0 & duplicate_latlong == 0, by(t2vt1)

ttest demtherm if democrat == 1 & duplicate_ip == 0, by(t3vt2)
ttest demtherm if democrat == 1 & duplicate_ip == 0 & duplicate_latlong == 0, by(t3vt2)

ttest reptherm if republican == 1 & duplicate_ip == 0, by(t2vt1)
ttest reptherm if republican == 1 & duplicate_ip == 0 & duplicate_latlong == 0, by(t2vt1)

log close _all
